<template>
  <div class="upload-container">
    <el-upload
      v-if="!disableUpload"
      :data="appendParams"
      :headers="headers"
      :on-success="handleSuccess"
      :http-request="onUpload"
      :action="action"
      :accept="acceptData"
      :limit="uploadOptions.limit"
      :file-list="fileList"
      :disabled="disableUpload"
      :on-exceed="onExceed"
      :multiple="multiple"
      :on-remove="handleRemoveFile"
    >
      <el-button
        size="small"
        type="primary"
      >点击上传</el-button>
      <div
        slot="tip"
        class="el-upload__tip"
      >
        <slot name="tips">
          <div v-if="tips">
            {{ tips }}
          </div>
        </slot>
      </div>
    </el-upload>
  </div>
</template>

<script>
import upload from '../mixins/upload'
export default {
  name: 'Temp',
  mixins: [upload],
  created() {
    console.log(this.acceptData)
  },
  methods: {
    onUpload(file) {
      console.log('method onUpload at upload mixins.')
      const formData = new FormData()
      formData.append('file', file.file)
      this.uploadAction(formData, 'file').then(res => {
        this.handleSuccess(res, file)
      })
    }
  }
}
</script>
